<?php
namespace Admin\Model;
use Think\Model;
class SiteModel extends Model
{
    public function search($pageSize = 10, $isDelete = 0)
    {
        $serch=I('get.');
        $where=array();
        //名字查询
        if (!empty($serch['NAME'])){
            $NAME=$serch['NAME'];
            $where['b.NAME']=array('like',"%$NAME%");
        }

        $count = M('Site')->where($where)->count();
        $page = new \Think\Page($count, $pageSize,$_GET);
        // 配置翻页的样式
        $page->setConfig('prev', '&lt;&lt;');
        $page->setConfig('next', '&gt;&gt;');
        $data['page'] = $page->show();
        //获取分页数据
        $data['data'] = M('Site')->where($where)->order('id DESC')->limit($page->firstRow.','.$page->listRows)->select();
        //总条数
        $data['count'] = $count;
        return $data;
    }

    public function site_list(){
        $data = M('Site')->field('id,site_name')->order('id DESC')->select();
        return $data;
    }

    // 添加前
    protected function _before_insert(&$data, $option)
    {
        $data['add_time'] = time();
    }
}